import axios from "axios";
const baseUrl = import.meta.env.VITE_APP_BASEURL;
const request = axios.create({
  baseURL: baseUrl,
  timeout: 300000,
  withCredentials: true,
  headers: {
    "Content-Type": "application/json",
  },
});
request.interceptors.request.use(
  (config: any) => {
    config.headers.token = "";
    return config;
  },
  (error: any) => {
    Promise.reject(error);
  }
);

request.interceptors.response.use(
  async (response: any) => {
    if (response.data.code && Number(response.data.code) != 200) {
      ElMessage.error(response.data.message);
    }
    return response.data;
  },
  (error: any) => {
    return Promise.reject(error);
  }
);
export default request;
